<!--本页面由uniapp切片工具生成，uni-app切片-可视化设计工具(一套代码编译到7个平台iOS、Android、H5、小程序)，软件下载地址：http://www.ymznkf.com/new_view_669.htm -->
<template>
	
	<view class="YmContent">
			<view class="my_1">
				<view class="my_2">
					<view class="my_6">
						<image v-on:click=""  :src="userInfo.avatar" mode="scaleToFill" border="0"    class="my_7"></image>
						<text decode="true" class="my_8">{{userInfo.nickname}}</text>
						<image v-on:click=""  src="/static/my/images/my_9_9.jpg" mode="scaleToFill" border="0"    class="my_9"></image>
					</view>
					<text decode="true" class="my_10">{{userInfo.unit}}</text>
					<view class="my_13">
					</view>
					<text decode="true" class="my_14">{{userInfo.position}}</text>
				</view>
				<view class="my_4">
				<!-- 	<view class="my_31">
						<image v-on:click=""  src="/static/my/images/my_23_23.jpg" mode="scaleToFill" border="0"    class="my_23"></image>
						<text decode="true" class="my_24">修改密码</text>
						<image v-on:click=""  src="/static/my/images/my_25_25.jpg" mode="scaleToFill" border="0"    class="my_25"></image>
					</view> -->
					<view class="my_31"  @click="shiming()">
						<image v-on:click=""  src="/static/my/images/my_23_23.jpg" mode="scaleToFill" border="0"    class="my_23"></image>
						<text decode="true" class="my_24">实名认证</text>
						<image v-on:click=""  src="/static/my/images/my_25_25.jpg" mode="scaleToFill" border="0"    class="my_25"></image>
					</view>
					<view class="my_32"  @click="kabao()">
						<image v-on:click=""  src="/static/my/images/my_27_27.jpg" mode="scaleToFill" border="0"    class="my_27"></image>
						<text decode="true" class="my_28">添加会员卡到微信</text>
						<image v-on:click=""  src="/static/my/images/my_29_29.jpg" mode="scaleToFill" border="0"    class="my_29"></image>
					</view>
					
				</view>
				<view class="my_5" @click="my_19_19_click()">
					<image v-on:click=""  src="/static/my/images/my_17_17.jpg" mode="scaleToFill" border="0"    class="my_17"></image>
					<text decode="true" class="my_18" >退出登陆</text>
					<image v-on:click=""  src="/static/my/images/my_19_19.jpg" mode="scaleToFill" border="0"    class="my_19"></image>
				</view>
			</view>
		

		<view class="loading">{{loadingText}}</view>
		<view class="ymBbottom"></view>
	</view>
</template>

<script>
export default {
		data() {
			return {
				userInfo:{},
			}
		},
		onShow:function() {
			this.userInfo=uni.getStorageSync('username');
			console.log(this.userInfo)
        },methods: {
			shiming(){
				uni.navigateTo({
					 url: '/pages/index/shiming'
				});
			},
			kabao(){
			uni.showLoading({
			       title: "加载中"
			   });
			   
			   uni.request({
			   	url: this.websiteUrl+'/api/index/get_vip_code_sign',
			   	method: 'POST',
			   	data: {username:this.username, password:this.password},
			   	header: {
			   	     "Content-Type": "application/x-www-form-urlencoded",
			   		 "token": uni.getStorageSync('username').token,
			   		 
			   	}, // 请求头
			   	success: res => {
			   		if	(res.data.code != 1){
			   			return uni.showToast({
			   				title:res.data.msg ? res.data.msg :'网络错误',
			   			});
			   		}
					
					
					wx.addCard({
					     cardList: [
					       {
					         cardId:res.data.data.card_id,
							  cardExt: JSON.stringify({"code": res.data.data.code, "openid": "", "nonce_str": res.data.data.nonce_str, "timestamp": res.data.data.timestamp, "signature":res.data.data.signature})
					       // cardExt: '{"code": 1000000010, "openid": "", "nonce_str": "test", "timestamp": "1612768379", "signature":"f9bb680adfc8afea493b31b65f0bef1f456530a8"}'
					       }
					     ],
					     success (res) {
							 
					       console.log(res.cardList) // 卡券添加结果
						   //添加成功后激活会员卡
						   uni.request({
						   	url: this.websiteUrl+'/api/index/jihuo_vip',
						   	method: 'POST',
						   	data: {username:this.username, password:this.password},
						   	header: {
						   	     "Content-Type": "application/x-www-form-urlencoded",
						   		 "token": uni.getStorageSync('username').token,
						   		 
						   	}, // 请求头
						   	success: res => {
						   		if	(res.data.code != 1){
						   			return uni.showToast({
						   				title:res.data.msg ? res.data.msg :'网络错误',
						   			});
						   		}
						   		uni.showToast({
						   			title:"添加成功",
						   			duration:2000,
						   			success() {
						   			
						   			}
						   		});
						   	},
						   	fail: () => {},
						   	complete: () => {
						   		
						   	}
						   });
					     }
					   })
					
					
					//{code: 1000000010, timestamp: 1612768258, api_ticket:
					 //"IpK_1T69hDhZkLQTlwsAX6ENORhrgDm8D4dkFUFPAzRoXh--I5G-GJxjYM5jiMkRyq5Op7vmUZie2-sPj3OxwQ", 
					 //card_id: "pO0ubwzcnlCfOsCj1M-LFGrbUfHE", nonce_str: "test", …}
			   		console.log(res.data.data)
			   		
			   	},
			   	fail: () => {},
			   	complete: () => {
			   		
			   	}
			   });
			   
			
			setTimeout(function () {uni.hideLoading();}, 100);	
			},
			my_19_19_click(){
				
				uni.request({
					url: this.websiteUrl+'/api/user/logout',
					method: 'POST',
					data: {username:this.username, password:this.password},
					header: {
					     "Content-Type": "application/x-www-form-urlencoded",
						 "token": uni.getStorageSync('username').token,
						 
					}, // 请求头
					success: res => {
						if	(res.data.code != 1){
							return uni.showToast({
								title:res.data.msg ? res.data.msg :'网络错误',
							});
						}
						uni.showToast({
							title:"退出成功",
							duration:2000,
							success() {
							uni.clearStorageSync();
							uni.navigateTo({
								 url: '/pages/index/login'
							});
							}
						});
						
					},
					fail: () => {},
					complete: () => {
						
					}
				});
			}
		}

	}

</script>

<style lang="scss" scoped>
   @import './my.scss'
</style>